<?php // abk.php Articles by Keywords Search.
require_once('./inc/inc.common.php');
$tmpl 			= new mvTemplate();
if(isset($_REQUEST['keyword_list'])) $_REQUEST['search'] = $_REQUEST['keyword_list'];

$tmpl->page_title('Search Results for "'.$_REQUEST['search'].'"');

if(!isset($_REQUEST['page'])){
	$limit = " LIMIT " . mvSettings::get('db_max_rec');
	$page = 1;
}else{
	$pagestart = ($_REQUEST['page'] - 1) * mvSettings::get('db_max_rec');
	$limit = " LIMIT " . mvSettings::get('db_max_rec');
	$page = $_REQUEST['page'];
}

$sql = "SELECT SQL_CALC_FOUND_ROWS FileID, Title, Articledata, SubmitDate FROM articles WHERE MATCH(Keyw) AGAINST (? IN BOOLEAN MODE) AND parentID = 0 AND Approved = 'Y' ORDER BY MATCH(Keyw) AGAINST (? IN BOOLEAN MODE) DESC " . $limit;
$parms = array($_REQUEST['search'], $_REQUEST['search']);
$query = $GLOBALS['db']->prepare_execute($sql, $parms);
$results = $query->fetchall();
$maxpage = $query->mysql_num_rows();

$tmpl->assign('results', $results);
$tmpl->assign('search', $_REQUEST['search']);
$tmpl->assign('page', $page);
$tmpl->assign('max_page', ceil($maxpage / mvSettings::get('db_max_rec')) );

$tmpl->page_display('abk.tpl');
?>